package com.taiyuan.tongcheng.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.kymjs.kjframe.utils.KJLoger;

/**
 * 
* @Description 线程池
* @author wzq
* @date 2015-8-12 上午11:34:58
* @update (date)
* @version V1.0
 */
public class ThreadPoolManager {
	private ExecutorService service;

	private ThreadPoolManager() {
		int num = Runtime.getRuntime().availableProcessors();
		KJLoger.debug("当前系统的核数"+String.valueOf(num));
		service = Executors.newFixedThreadPool(num * 2);
	}

	private static ThreadPoolManager manager;

	public static ThreadPoolManager getInstance() {
		if (manager == null) {
			manager = new ThreadPoolManager();
		}
		return manager;
	}

	public void addTask(Runnable runnable) {
		service.submit(runnable);
	}

}
